package ua.com.infopulse.activities;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;


import java.util.Date;
/*
*  Author: Andrew.Nazymko
*/

import ua.com.infopulse.R;
import ua.com.infopulse.TransferKey;
import ua.com.infopulse.db.DBGetter;
import ua.com.infopulse.db.DataTrackManager;
import ua.com.infopulse.spesial_data.LocationData;

/**
 * Activity for showing detail info about point
 */
public class PointInfo extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.check_in_point);
        int id = getIntent().getExtras().getInt(TransferKey.ID);
        DataTrackManager manager = DBGetter.getDTM();
        LocationData locationForId = manager.getLocationForId(id);
        ((TextView) findViewById(R.id.description)).setText("Note:" + locationForId.getDescription());
        String latitude = String.valueOf(locationForId.getLatitude());
        ((TextView) findViewById(R.id.latitude)).setText("Latitude:" + latitude);
        String longitude = String.valueOf(locationForId.getLongitude());
        ((TextView) findViewById(R.id.longitude)).setText("Longitude:" + longitude);
        ((TextView) findViewById(R.id.time)).setText("Time:" + new Date(locationForId.getTime()));
        TextView link = (TextView) findViewById(R.id.map);
        link.setMovementMethod(LinkMovementMethod.getInstance());
        link.setText(Html.fromHtml("<a href=\"" + "https://maps.google.com/maps?&geocode=&q=" + latitude + "," + longitude + "\"><u>Watch at map</u></a>"));

    }


}
